package converter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;

import com.totoro.domain.ProjectCategory;
import com.totoro.service.ProjectCategoryService;


/**
 * @author Acer
 * 将JSP中的ProjectCategory.id从String形式转换成ProjectCategory对象
 * 需要bysj-servlet.xml中配置
 */
public class StringToCategory implements Converter<String, ProjectCategory> {
	@Autowired
	private  ProjectCategoryService projectCategoryService;

	@Override
	public ProjectCategory convert(String string) {
		System.out.println("Convert Category:" + string);
		return projectCategoryService.get((new Integer(string)));
	}

}
